%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This file is part of the book
%%
%% Algorithmic Graph Theory
%% http://code.google.com/p/graphbook/
%%
%% Copyright (C) 2009--2013 Minh Van Nguyen <mvngu.name@gmail.com>
%%
%% See the file COPYING for copying conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{algorithmic}[1]
%% input and output
\Require A polynomial $p(x) = \sum_{i=0}^n a_i x_i$, where $a_n \neq 0$
  and $x_0 \in \R$.
\Ensure An evaluation of $p$ at $x = x_0$.
%%
%% algorithm body
\State $b \gets a_n$
\For{$i \gets n - 1, n - 2, \dots, 0$}
  \State $b \gets b x_0 + a_i$
\EndFor
\State \Return $b$
\end{algorithmic}
